<template>
  <div>
    <MyHeader
      title="HomeWork TabBar"
      backgroundColor="orange"
      color="green"
    ></MyHeader>
    <div class="main">
      <component :is="currentPage"></component>
    </div>
    <!-- 样式有了 然后铺设数据   传数据-->
    <MyTabBar :arr="tabList" @tabbar="changeFn"></MyTabBar>
  </div>
</template>

<script>
// 头底排版
import MyHeader from "./components/MyHeader";
import MyTabBar from "./components/MyTabBar";
// 页面
import MyGoodsList from "./views/MyGoodsList";
import MyGoodsSearch from "./views/MyGoodsSearch";
import MyUserInfo from "./views/MyUserInfo";
export default {
  components: {
    MyHeader,
    MyTabBar,
    MyGoodsList,
    MyGoodsSearch,
    MyUserInfo,
  },
  data() {
    return {
      tabList: [
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList",
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "MyGoodsSearch",
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "MyUserInfo",
        },
      ],
      currentPage: "MyGoodsList",
    };
  },
  methods: {
    changeFn(index) {
      this.currentPage = this.tabList[index].componentName;
    },
  },
};
</script>

<style>
.main {
  padding: 50px 0;
}
</style>